This project is a comprehensive Bash-based network security scanner that performs vulnerability assessment of target hosts and generates detailed security reports. The scanner combines local vulnerability detection with live data from the NIST National Vulnerability Database (NVD) to provide thorough security analysis.
- Comprehensive Port Scanning: Uses nmap with service version detection
- Vulnerability Detection: Employs NSE (Nmap Scripting Engine) vulnerability scripts
- Local Vulnerability Database: Built-in checks for known vulnerable service versions
- NVD API Integration: Live CVE data retrieval from NIST National Vulnerability Database
- Detailed Reporting: Well-formatted security reports with remediation recommendations
- Command-line Interface: Full argument parsing with help and version options
The scanner identifies at least 8+ potential vulnerability categories:
- Outdated Service Versions: Apache, nginx, OpenSSH, MySQL, PHP, etc.
- Known Backdoors: vsftpd 2.3.4, etc.
- Insecure Protocols: Telnet, unencrypted FTP, HTTP
- Default Configurations: Default ports, weak authentication
- Legacy Software: End-of-life applications
- Directory Traversal: Apache path traversal vulnerabilities
- Remote Code Execution: Samba, IIS vulnerabilities
- Information Disclosure: SNMP, RPC services
- Authentication Bypass: MySQL, SSH vulnerabilities
- Buffer Overflow: Various service-specific vulnerabilities
- nmap: Network scanning and service detection
# Debian/Ubuntu sudo apt-get install nmap # RHEL/CentOS sudo yum install nmap # macOS brew install nmap
-
curl: For NVD API integration
# Debian/Ubuntu sudo apt-get install curl # RHEL/CentOS sudo yum install curl # macOS brew install curl
-
jq: For JSON parsing of NVD API responses
# Debian/Ubuntu sudo apt-get install jq # RHEL/CentOS sudo yum install jq # macOS brew install jq
-
Clone or Download: Get the script files
# Make the script executable chmod +x netscan.sh -
Verify Dependencies: The script will automatically check for required tools
./netscan.sh --help
./netscan.sh [OPTIONS] <target_ip_or_hostname>-h, --help: Display help message and usage examples-v, --version: Show version information and feature list
./netscan.sh scanme.nmap.org./netscan.sh 127.0.0.1./netscan.sh 192.168.1.1./netscan.sh www.example.comThe scanner generates:
- Console Output: Real-time progress and summary
- Report File:
security_scan_report.txtwith detailed findings
nmap -sV --script vuln -T4 --open <target>Explanation of flags:
-sV: Service version detection - identifies running services and their versions--script vuln: Runs all NSE vulnerability detection scripts-T4: Aggressive timing template for faster scanning--open: Only shows open ports to reduce noise
nmap -sV -T4 --open <target>Used when the primary command fails, provides basic service detection without vulnerability scripts.
- Executes nmap's built-in vulnerability scripts
- Searches for keywords: "VULNERABLE", "CVE-", "CRITICAL", "HIGH RISK"
- Provides immediate identification of known exploits
- Parses nmap output for specific vulnerable versions
- Uses conditional logic (case statements) to match known vulnerable software
- Covers major services: Apache, nginx, OpenSSH, MySQL, PHP, Samba, IIS
- Identifies insecure protocols (Telnet, unencrypted FTP)
- Flags potentially dangerous services (SNMP, RPC, VNC)
- Checks for services on default ports
- Queries NIST National Vulnerability Database for live CVE data
- Provides authoritative vulnerability information
- Includes CVSS scores and detailed descriptions
- Target information
- Scan timestamp
- Scanner version
- Port numbers and protocols
- Service names and versions
- Service fingerprints
- NSE vulnerability results
- Service version vulnerabilities
- Additional security concerns
- NVD API enriched data
- Immediate actions required
- Security hardening steps
- Ongoing security practices
- Report generation timestamp
- Tool version information
- Legal disclaimer
- Automatic verification of required tools
- Clear installation instructions for missing dependencies
- Graceful degradation when optional tools are unavailable
- Ping connectivity testing with fallback
- nmap command failure recovery
- API timeout and error handling
- Command-line argument validation
- Target format verification
- Error messages with usage instructions
- Authorization Required: Only scan systems you own or have explicit permission to test
- Responsible Disclosure: Report vulnerabilities through proper channels
- Compliance: Follow local laws and regulations regarding network scanning
- Use designated test targets (like scanme.nmap.org) for learning
- Avoid aggressive scanning of production systems
- Respect rate limits when using external APIs
- Document and report findings responsibly
- NVD API integration includes built-in rate limiting
- Configurable result limits to avoid API blocking
- Defensive programming for API failures
- Functions: Separate functions for each major component
- Error Handling: Comprehensive error checking and recovery
- Configuration: Easy modification of scan parameters
- Extensibility: Simple addition of new vulnerability checks
check_dependencies(): Verify required toolsperform_nmap_scan(): Execute network scanningwrite_header(): Generate report headerwrite_ports_section(): Format port informationwrite_vulns_section(): Analyze and report vulnerabilitiesquery_nvd(): Interface with NVD APIwrite_recs_section(): Generate recommendationswrite_footer(): Complete report formatting
This project was developed through multiple iterations:
- Static Report Template: Basic report structure and formatting
- Dynamic Framework: Command-line arguments and function modularization
- Live Scanning: Integration with nmap for real network data
- Version Control: Git repository setup and management
- Vulnerability Analysis: NSE scripts and local vulnerability database
- API Integration: NVD database connectivity for live CVE data
- Edit the
write_vulns_section()function - Add new case patterns for vulnerable services
- Include CVE references and remediation advice
- Test against known vulnerable targets
- Modify the
query_nvd()function - Add error handling for new scenarios
- Implement additional data sources
- Ensure rate limiting compliance
This project is developed for educational purposes. Use responsibly and in accordance with applicable laws and ethical guidelines.
- v3.0: Full-featured scanner with NVD API integration
- v2.0: Added NSE vulnerability detection and local database
- v1.0: Basic port scanning and report generation
For issues or questions:
- Check the built-in help:
./netscan.sh --help - Verify dependencies are installed
- Test with known targets like scanme.nmap.org
- Review error messages for troubleshooting guidance
Disclaimer: This tool is intended for authorized security testing only. Users are responsible for ensuring they have proper authorization before scanning any network resources.
- Live Port Scanning: Uses nmap with service version detection (
-sV) - Host Reachability Check: Ping verification before scanning
- Structured Reporting: Professional report format with timestamps
- Error Handling: Graceful fallback if nmap is not available
- Input Validation: Proper argument checking and usage instructions
- Multiple Target Support: Works with IP addresses, hostnames, and localhost
- Header: Target information and scan timestamp
- Open Ports and Detected Services: Live nmap scan results with service versions
- Potential Vulnerabilities: Framework ready for vulnerability assessment
- Recommendations: Security hardening suggestions
- Footer: Report metadata and generation information
A comprehensive bash script for performing network security assessments and generating detailed vulnerability reports.
This project is a command-line network security scanner that performs live port scanning using nmap and generates structured security reports. The scanner identifies open ports, running services, and provides a foundation for vulnerability assessment and security recommendations.
This project was developed as part of a bash scripting course focusing on:
- Master fundamental Linux command-line operations
- Understand and apply text processing techniques in Linux
- Develop and implement shell scripts for automation
- Apply scripting to security hardening and auditing
- Integrate external tools and commands within scripts
- Demonstrate understanding of scripting security best practices
- Live Port Scanning: Uses nmap with service version detection (
-sV) - Host Reachability Check: Ping verification before scanning
- Structured Reporting: Professional report format with timestamps
- Error Handling: Graceful fallback if nmap is not available
- Input Validation: Proper argument checking and usage instructions
- Multiple Target Support: Works with IP addresses, hostnames, and localhost
- Header: Target information and scan timestamp
- Open Ports and Detected Services: Live nmap scan results with service versions
- Potential Vulnerabilities: Framework ready for vulnerability assessment
- Recommendations: Security hardening suggestions
- Footer: Report metadata and generation information
Once you’ve enumerated open ports and services, you need to translate that raw data into professional findings. This section defines the key terms your scanner will reference in its report.
The attack surface is the sum of all points where an attacker could try to enter or extract data.
In your script: each open port and service you discover expands the target’s attack surface.
Enumeration is actively gathering information—live hosts, open ports, service versions, usernames, shares—to discover attack vectors.
In your script:
nmap -sVservice-version detection is your enumeration phase.
A vulnerability is a flaw in design, implementation, or configuration that can be exploited.
In your script: an open port alone isn’t a vulnerability, but vsftpd 2.3.4 on port 21 is (because it has a known CVE backdoor).
A CVE ID (e.g. CVE-2021-44228) uniquely labels a publicly known vulnerability.
In your script: map service versions to their CVEs (e.g. “Apache httpd 2.4.48 → CVE-2021-40438”).
An exploit is code or a technique that actively leverages a vulnerability.
In your script: do not include exploit code—your role is reporting, not attacking.
- Scan Target: run your scanner against an IP.
- Map Attack Surface: list open ports/services.
- Perform Enumeration: gather service versions (
nmap -sV). - Identify Vulnerabilities: lookup associated CVEs.
- Report Findings: output “Port 80/tcp: Apache httpd 2.4.48 (CVE-2021-40438).”
- (Out of scope) Exploitation: would be the attacker’s next step.
- Bash shell (compatible with macOS, Linux)
- nmap - Network scanning tool
- Standard Unix utilities: ping, grep, etc.
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install nmap./netscan.sh <target_ip_or_hostname># Scan a test server
./netscan.sh scanme.nmap.org
# Scan localhost
./netscan.sh 127.0.0.1
# Scan a specific IP address
./netscan.sh 192.168.1.1./netscan.sh
# Displays usage information and examples===============================
Network Security Scan Report
===============================
Target IP/Hostname: scanme.nmap.org
Scan Date: Fri 1 Aug 2025 21:42:07 PKT
--- Open Ports and Detected Services ---
[+] Running nmap scan on scanme.nmap.org...
[+] This may take a moment...
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
9929/tcp open nping-echo Nping echo
31337/tcp open tcpwrapped
--- Potential Vulnerabilities Identified ---
- Vulnerability assessment pending
- Manual review recommended
- Consider running additional security tools
--- Recommendations for Remediation ---
- Update all software packages to latest versions
- Apply available security patches
- Implement proper firewall rules
- Review and harden service configurations
- Consider implementing intrusion detection systems
The scanner follows a modular function-based design:
main()- Primary execution flow and argument validationis_alive()- Host reachability verificationwrite_header()- Report header generationwrite_ports_section()- Live nmap scanning and port detectionwrite_vulns_section()- Vulnerability assessment frameworkwrite_recs_section()- Security recommendationswrite_footer()- Report conclusion and metadata